package com.zhongjianjian.leguansuo.dao;

import com.zhongjianjian.redisLock.entity.TestStock;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 作者: LCG
 * 日期: 2020/2/22 00:18
 * 描述:
 */
@Mapper
public interface TestLgDao {


    @Update("update base_stock set stock=#{stock},version=version+1 where goods_id=#{goodsId} and version=#{version}")
    public int updateStock(TestStock testStock);


    @Select("select * from base_stock where goods_id=#{goodsId}")
    @Results(
            value = {
                    @Result(property = "createDate",column = "create_time",jdbcType = JdbcType.DATE),
                    @Result(property = "version",column = "version",jdbcType = JdbcType.INTEGER),
                    @Result(property = "stock",column = "stock",jdbcType = JdbcType.INTEGER),
                    @Result(property = "goodsId",column = "goods_id",jdbcType = JdbcType.BIGINT)
            }
    )
    public TestStock getStock(TestStock testStock);

}
